/**********************************************************************************************************************
 * @file    MX25_l256.h
 * @author  Queclink Terry.Huang
 * @date    2020-08-19
 * @brief   mx25_l256 read/write/other operation interface implementation.
 *
 * Copyright (C) 2020 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 *
 * @attention
 *
 **********************************************************************************************************************/

#ifndef _FLASH_DEV_MX25L256_H_
#define _FLASH_DEV_MX25L256_H_

#include <stdbool.h>
#include <flash/flash_cmn.h>

#ifdef __cplusplus
    extern "C"{
#endif

#define FLASH_ADDR_4BYTES_MODE      1
#define FLASH_ENTRY_4BYTES_SET      1

/*函数接口定义*/
const fdrv_adp_t fadp = {\
        .init           = flash_dev_init,\
        .read           = flash_dev_read,\
        .write          = flash_dev_write,\
        .erase_chip     = flash_dev_erase_chip,\
        .erase_sector   = flash_dev_erase_sector,\
        .erase_block    = flash_dev_erase_block,\
        .status         = flash_dev_status,\
        };

/*flash属性*/
const fchip_info_t fchip= {\
        .name           = "MX25L256",\
        .capacity       = SIZE_M(32),\
        .block_size         = SIZE_K(64),\
        .sector_size    = SIZE_K(4),\
        };

 /*flash操作最大的完成时间，单位ms，在芯片手册数值基础上加了20%余量*/
const unsigned int chip_erase_time = 250000;
const unsigned int block_erase_time = 2400;
const unsigned int sector_erase_time = 480;
const unsigned int page_program_time = 2;
const unsigned char manufacturer_id = 0xC2;

bool flash_support_4bytes_addr(void)
{
    return true;
}

bool flash_need_entry_4bytes_mode(void)
{
    return true;
}


#ifdef AADL_FLASH_DESTROY_CHK_USE
p_fun_flash_sector_check_t p_flash_sector_check = flash_if_add_sector_check_node;
#else
p_fun_flash_sector_check_t p_flash_sector_check = NULL;
#endif

#ifdef __cplusplus
    }
#endif

#endif
/** END FO FILE **/

